color_dict = {'purple': '紫色', 'green': '绿色', 'black': '黑色'}
print(color_dict['purple'])
print(color_dict['green'])
print(color_dict['black'])

if 'red' in color_dict:
    print(color_dict['red'])
else:
    print('键不存在')

    add_dict = {'stu1': '小明'}
    add_dict.update(stu2='小刚')
    add_dict['stu3'] = '小兰'
    print(add_dict)

modify_dict = {'stu1': '小明', 'stu2': '小刚', 'stu3': '小兰'}
modify_dict.update(stu2='小强')
modify_dict['stu3'] = '小婷'
print(modify_dict)


